"""
一共有四种锻造方法
木棍n     钻石m
1         2
2         1
2         2
2         3
"""

# 暴力深度优先搜索确实能骗到一部分分
# 开始有点懂深度搜索怎么写了
result_list = []


def dfs(n, m, now_n, now_m, count):
    if now_n > n or now_m >m:
        result_list.append(count-1)
        return
    # 以下递归搜索4种可能性
    dfs(n, m, now_n+1, now_m+2, count+1)
    dfs(n, m, now_n+2, now_m+1, count+1)
    dfs(n, m, now_n+2, now_m+2, count+1)
    dfs(n, m, now_n+2, now_m+3, count+1)
    pass


def resolution1():
    T = int(input())
    for i in range(T):
        n, m = map(int, input().split(" "))
        result_list.clear()
        dfs(n, m, 0, 0, 0)
        print(max(result_list))
    pass


if __name__ == '__main__':
    resolution1()